<template>
<div>
    <van-nav-bar
  title="修改个人信息"
  left-text="返回"
  left-arrow
  :fixed="true"
  @click-left="onClickLeft"
/>

<van-form @submit="onSubmit">
  <van-field
    v-model="nickname"
    name="昵称"
    label="昵称"
    placeholder="昵称"
    
  />
  <van-field
    v-model="sex"
    name="性别"
    label="性别"
    placeholder="性别"
    
  />
  <van-field
    v-model="tel"
    name="手机号"
    label="手机号"
    placeholder="手机号"
    
  />
  <div style="margin: 16px;">
    <van-button round block type="info" native-type="submit" @click="tijiao">提交</van-button>
  </div>
</van-form>

</div>
</template>
<script>
import { Toast } from 'vant';

export default {
     data() {
    return {
      nickname: '',
      sex: '',
      tel:'',
    };
  },
  methods: {
    onSubmit(values) {
      console.log('submit', values);
    }
  },
    
  methods: {
    onClickLeft(){
          this.$router.go(-1)
    },

    tijiao:function(){
      this.$axios.put('/updateinspector2',{nickName:this.nickname,sex:this.sex,phoneNumber:this.tel,id: localStorage.getItem("insceptorid")})
      .then(res=>{
        if(res.data.msg==200){
          var nn = res.data.data.nickName
         localStorage.setItem("nickName",nn)
          alert("修改成功")
            this.$router.push({path:'/my'})
        }else{
          alert("修改失败请重新尝试")
        }
      })
      .error(error=>{
        alert("修改失败请重新尝试")
      });
      
    }
    }

}
</script>

